package com.lsh.oms.provider.service.order.frozen;

import com.lsh.oms.api.service.query.IFindFrogenOrderService;

/**
 * Project Name: lsh-oms
 *
 * @author miaozhuang
 * @date 17/3/27
 * 北京链商电子商务有限公司
 * Package
 * desc:
 */
//@Service(protocol = "rest")
//@Path("frogen/order")
//@Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.MULTIPART_FORM_DATA,MediaType.APPLICATION_JSON})
//@Produces({ ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8 })
    @Deprecated
public class FrogenOrderDealRestServiceImpl implements IFindFrogenOrderService {

//    @GET
//    @Path("deal")
//    @Override
//    public CommonResult<Object> transferOrderDelivery(@QueryParam("orderCode") Long orderCode) {
////
////        logger.info("transferOrderDelivery params is {}",orderCode);
//        CommonResult<Object> commonResult = new CommonResult<>();
//        try {
//            if(orderCode == null){
//                throw new BusinessException(ReturnCode.REQUEST_PARAMS_IS_NULL,"请求参数不合法，请检验。");
//            }
//            OrderHead orderHead = orderQueryService.findByCode(orderCode,false,true);
//            if (orderHead == null) {
//                throw new BusinessException(ReturnCode.FIND_ORDER_IS_NULL,"用户订单号未查询到订单");
//            }
//            int orderStatus =  orderHead.getOrderStatus();
//            if(orderStatus == OrderStatus.ORDER_NO_EDIT.getIndex()){
//                throw new BusinessException(ReturnCode.REQUEST_FAIL, "订单状态不符，请刷新重试或联系技术处理。订单状态为`" + OrderStatus.getName(orderStatus));
//            }
//            if(orderStatus == OrderStatus.ORDER_DELIVERY.getIndex()){
//                throw new BusinessException(ReturnCode.ORDER_DEAL, "订单状态为已处理，请刷新重试或联系技术处理。");
//            }
//            if(orderStatus >= OrderStatus.ORDER_CANCEL_CUSTOMERSERVICE.getIndex()){
//                throw new BusinessException(ReturnCode.ORDER_CANCEL, "订单已取消，无法操作，请刷新。");
//            }
//            OrderShippingHeadDto orderShippingHeadDto = new OrderShippingHeadDto();
//            orderShippingHeadDto.setShippingOrderId(IdGenerator.uuid());
//            orderShippingHeadDto.setOrderId(orderCode);
//            List<OrderShippingDetailDto> details = new ArrayList<>();
//            orderShippingHeadDto.setDetails(details);
//            List<OrderDetail> orderDetails = orderHead.getDetails();
//
//            if(orderDetails == null){
//                throw new BusinessException(ReturnCode.FIND_ORDER_IS_NULL, "订单详情信息，请核实！");
//            }
//
//            OrderShippingDetailDto detailDto;
//            for(OrderDetail orderDetail : orderDetails){
//                detailDto = new OrderShippingDetailDto();
//                details.add(detailDto);
//
//                detailDto.setSkuId(orderDetail.getGoodsCode());
//                detailDto.setItemId(orderDetail.getSkuCode());
//                detailDto.setRealQty(orderDetail.getQuantity().multiply(orderDetail.getGoodsSaleUnit()));
//            }
//
//            //已经验证过订单存在，所以此处不验证明细为空
//            if (orderShippingHeadDto.getDetails() == null || orderDetails.size() < orderShippingHeadDto.getDetails().size()) {
//                logger.info(orderHead.getOrderCode() + "传入明细数量大于下单数量");
//                throw new BusinessException(ReturnCode.REQUEST_FAIL, "明细数量大于订单明细数量，请核实");
//            }
//
//            commonResult = this.orderDeliveryFrozenService.createShippingOrder4Frogen(orderShippingHeadDto,orderHead,""+orderCode);
//
//        } catch (BusinessException e) {
//            commonResult.setCode(e.getCode());
//            commonResult.setMessage(e.getMessage());
//            logger.error("业务异常code : " + e.getCode() + ",异常信息: " + e.getMessage(),e);
//        } catch (Exception e) {
//            commonResult.setCode(ExceptionStatus.E3001001.getCode());
//            commonResult.setMessage(ExceptionStatus.E3001001.getMessage());
//            logger.error("业务异常code : " + ExceptionStatus.E3001001.getCode() + ",异常信息: " + e.getMessage(),e);
//        }
//
//        return commonResult;
//    }

}
